home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / unix / flex_2_3 / part06 < prev    next >
Encoding:
Internet Message Format  |  1990-08-19  |  61.3 KB

  1. Path: abcfd20.larc.nasa.gov!amiga-request
  2. From: amiga-request@abcfd20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
  3. Subject: v90i233: flex 2.3 - fast lexical analyzer generator, Part06/13
  4. Reply-To: loftus@wpllabs.uucp (William P Loftus)
  5. Newsgroups: comp.sources.amiga
  6. Message-ID: <comp.sources.amiga:v90i233@abcfd20.larc.nasa.gov>
  7. Date: 19 Aug 90 22:42:41 GMT
  8. Approved: tadguy@uunet.UU.NET (Tad Guy)
  9. X-Mail-Submissions-To: amiga@uunet.uu.net
  10. X-Post-Discussions-To: comp.sys.amiga
  11.  
  12. Submitted-by: loftus@wpllabs.uucp (William P Loftus)
  13. Posting-number: Volume 90, Issue 233
  14. Archive-name: unix/flex-2.3/part06
  15.  
  16. #!/bin/sh
  17. # This is a shell archive.  Remove anything before this line, then unpack
  18. # it by saving it into a file and typing "sh file".  To overwrite existing
  19. # files, type "sh file -c".  You can also feed this as standard input via
  20. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  21. # will see the following message at the end:
  22. #        "End of archive 6 (of 13)."
  23. # Contents:  MISC/Atari.patches flexdef.h
  24. # Wrapped by tadguy@abcfd20 on Sun Aug 19 18:41:45 1990
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f 'MISC/Atari.patches' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'MISC/Atari.patches'\"
  28. else
  29. echo shar: Extracting \"'MISC/Atari.patches'\" \(29474 characters\)
  30. sed "s/^X//" >'MISC/Atari.patches' <<'END_OF_FILE'
  31. X(Message inbox:32)
  32. XDate:          Mon, 03 Jul 89 21:15:32 CET
  33. XFrom:  V61%DHDURZ1.BITNET@lbl.gov
  34. XSubject:       Flex, bug fix, improvments, patches for Minix & TOS
  35. XTo:  vern@lbl-csam.arpa
  36. X
  37. XAt first I have to thank you for your wonderful program. I had ported the
  38. Xold version to OS9,TOS (Atari ST) and Minix and the new version 2.1 Beta
  39. Xto Minix and TOS.
  40. X     
  41. XWhile porting and using flex I detected a bug and made some improvements.
  42. XI have included a  shared, compressed and uuencoded file contaning all cdiffs
  43. Xand additional files (Sorry, but I'm on EBCDIC-Bitnet) and a short discussion
  44. Xof the changes. Even some of the TOS specific changes might be of general
  45. Xinterest !
  46. X     
  47. XI posted these cdiffs to the minix discussion group, but I think it's up
  48. Xto you to post them to the unix-sources group. If you plan to post even
  49. Xthe TOS compiler specific patches please contact me because there might be
  50. Xfurther compiler (P.D.) additions. If you have an interest I could also
  51. Xport the new version to OS9 -- this is a little bit more difficult, because
  52. XOS9 uses CR as end of line character (the EOL char. is coded into the
  53. Xinitscan.c tables,...). It is necessary to change all occurences of '\n' to
  54. Xmacros and variables and it's useful to add a new -n options (see commented
  55. Xline in main.c)
  56. X     
  57. X     
  58. X     
  59. XThe changes:                                                  (1.7.89 RAL)
  60. X     
  61. X - Bug fix: The original flex didn't like trailing spaces in exclusive start
  62. X     condition lists ! If you add an trailing space to line 68 in scan.l
  63. X     
  64. X     "%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE "
  65. X     
  66. X     you get a misleading error message:
  67. X     
  68. X     "Syntax error at line 69: bad start condition list"
  69. X     
  70. X     This bug can either be fixed in parse.y or in scan.l . I have chosen the
  71. X     last because there the fix is minimal: Just change the rule (line 128)
  72. X     
  73. X      "\n"    to   "{OPTWS}\n"
  74. X     
  75. X - Enhancements:
  76. X    - new option "-?" that provides some help information about the other
  77. X      flags (main.c)
  78. X    - new option "-aTMPPATH" that allows a redefinition of the standard
  79. X      path for the temporary file (this might be rather large >200k if
  80. X      F,f options are selected). (main.c, flexdef.h (l.376))
  81. X    - hexdump of illegal characters -- this proved to be a useful debugging
  82. X      tool especialy if invisible control characters occur which weren't
  83. X      covered by the rules. (scan.l  fprintf statement line 129,...)
  84. X     
  85. X - Patches due to TOS
  86. X    - General: TOS uses CR,LF as end of line char., Flex wants only a single
  87. X      LF as EOL char. Therefore all I/O must be translated using f* calls.
  88. X      This is done everywhere besides the YY_INPUT macro (flex.skel (scan.c),
  89. X      line 31) that uses a low level 'read'. This should be definitly changed
  90. X      to fread, so that all I/O calls occur on the same level.
  91. X    - the short action_file_name has been "flexXXXXXX.tmp", but that's too
  92. X      much for TOS,MSDOS ! I changed it to "flexXXXX.tmp" in main.c (patch
  93. X      covered by the -a option additions)
  94. X    - some compilers don't like external names that are ambiguous within
  95. X      the first 8 characters. I defined macros that change all these long
  96. X      external names to names that are unique within the first 8 characters.
  97. X      Just define SHORT_EXTERNAL_NAMES to use this feature (flexdef.h)
  98. X    - some statement changes that some compiler don't like:
  99. X      typedef *xxx[]  -> typedef **xxx       (flexdef.h.,l.308)
  100. X      "/*" -> '/','*' within a comment in (scan.l, l.209)
  101. X    - changed short "lexyy.c" to "lex_yy.c" what's more similar to the unix
  102. X      "lex.yy.c" (main.c).
  103. X    - a few further really compiler dependent changes provided with
  104. X      #ifdef ATARI && LATTICE res. TURBO braces.
  105. X     
  106. X - Additional TOS only files
  107. X    - Makefile.tos: Common makefile for all TOS compilers. If you add further
  108. X      ones please email me the new makefile.
  109. X    - flex.lnk: Lattice - GST linker argument extension file
  110. X    - flex.tlk: Turbo linker argument extension file
  111. X     
  112. X     
  113. XAdditional remarks:
  114. X     
  115. XI didn't add a new initscan.c (= flex -ist scan.l). The current one is good
  116. Xenough for a first compilation. With this first version of flex you can
  117. Xrebuild your own scan.c and the final flex version !
  118. X     
  119. XMinix ST :
  120. X  - I had to "chmem =70000 cv" (>50000) to get flex linked
  121. X  - 'memset' (PC 1.3, EFTH40,...) is necessary
  122. X  - chmem =90000 flex may be sufficient
  123. X     
  124. XMinix PC :
  125. X  It should be possible to port Flex to Minix PC. The current sizes of flex
  126. X  are:
  127. X                        Minix ST (ACK)    Lattice (TOS)    Turbo (TOS)
  128. X     
  129. X       size               75300             83305             57957
  130. X       compilation time      22'               15'             3'40"
  131. X       flex -is scan.l     1'49"               43"               30"
  132. X     
  133. X  The Minix ST size includes the bad generated code using only a subset of
  134. X  the 68000 commands, long addresses only and a huge relocation table.
  135. X  Therefore the PC size will be <64 k ! More serious is the fact that I had
  136. X  to chmem =90000 flex to get scan.l converted to scan.c . But I never saw
  137. X  a more complex lex source than scan.l -- so it should be possible to
  138. X  reduce some array sizes without limitation for all day usage.
  139. X     
  140. X  No one volunteered yet for a Minix PC port -- but if someone will try it
  141. X  I would provide him with a new scan.c and some hints.
  142. X     
  143. XTOS:
  144. X  Don't forget to adapt the flexskel path within flexdef.h !
  145. X     
  146. X     
  147. XBitnet:  V61@DHDURZ1                               Ronald Lamprecht
  148. XUUCP:    ...!unido!DHDURZ1.bitnet!V61              Theoretische Physik
  149. XARPAnet: V61%DHDURZ1.BITNET@CUNYVM.CUNY.EDU       (Heidelberg, West Germany)
  150. X(Message inbox:36)
  151. XDate:          Wed, 05 Jul 89 21:16:07 CET
  152. XFrom:  V61%DHDURZ1.BITNET@csa2.lbl.gov
  153. XSubject:       Re: What is TOS
  154. XTo:  vern@lbl-csam.arpa
  155. X
  156. XTOS is the name of the Atari ST operating system that is very similar
  157. Xto MSDOS (Both use CR,LF as end of line character). Therefore I have
  158. Xbeen astonished that no EOL convertion porblems occur within MSDOS.
  159. X     
  160. XI have been aware of the double buffering when changing read to fread and  I
  161. Xaccept your argument of a possible slow down. But if you integrate the other
  162. XAtari - TOS changes, please insert a
  163. X        #ifdef ATARI
  164. X              fread ....
  165. X        #else
  166. X              read  ....
  167. X        #endif
  168. Xin flex.skel .
  169. X     
  170. XBitnet:  V61@DHDURZ1                               Ronald Lamprecht
  171. XUUCP:    ...!unido!DHDURZ1.bitnet!V61              Theoretische Physik
  172. XARPAnet: V61%DHDURZ1.BITNET@CUNYVM.CUNY.EDU       (Heidelberg, West Germany)
  173. X
  174. X
  175. X
  176. X
  177. Xecho x - Makefile_cdiff
  178. Xsed '/^X/s///' > Makefile_cdiff << '/'
  179. XX*** Src_2.1/Makefile    Thu Jun 28 00:06:42 1989
  180. XX--- Makefile    Thu Jul  3 02:12:48 1989
  181. XX***************
  182. XX*** 5,10 ****
  183. XX--- 5,11 ----
  184. XX  # Porting considerations:
  185. XX  #
  186. XX  #    For System V Unix machines, add -DSYS_V to CFLAGS.
  187. XX+ #    For Minix (ST), add -DSYS_V to CFLAGS
  188. XX  #    For Vax/VMS, add -DSYS_V to CFLAGS.
  189. XX  #    For MS-DOS, add "-DMS_DOS -DSYS_V" to CFLAGS.  Create \tmp if not present.
  190. XX  #         You will also want to rename flex.skel to something with a three
  191. XX***************
  192. XX*** 21,28 ****
  193. XX  SKELETON_DIR = /usr/local/lib
  194. XX  SKELETON_FILE = flex.skel
  195. XX  SKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_DIR)/$(SKELETON_FILE)\"
  196. XX! CFLAGS = -O
  197. XX! LDFLAGS = -s
  198. XX  
  199. XX  FLEX_FLAGS =
  200. XX  FLEX = ./flex
  201. XX--- 22,29 ----
  202. XX  SKELETON_DIR = /usr/local/lib
  203. XX  SKELETON_FILE = flex.skel
  204. XX  SKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_DIR)/$(SKELETON_FILE)\"
  205. XX! CFLAGS = -O -DSYS_V
  206. XX! LDFLAGS = 
  207. XX  
  208. XX  FLEX_FLAGS =
  209. XX  FLEX = ./flex
  210. XX***************
  211. XX*** 57,63 ****
  212. XX      yylex.c
  213. XX  
  214. XX  flex : $(FLEXOBJS)
  215. XX!     $(CC) $(CFLAGS) -o flex $(LDFLAGS) $(FLEXOBJS)
  216. XX  
  217. XX  first_flex:
  218. XX      cp initscan.c scan.c
  219. XX--- 58,65 ----
  220. XX      yylex.c
  221. XX  
  222. XX  flex : $(FLEXOBJS)
  223. XX!     $(CC) $(CFLAGS) -o flex $(FLEXOBJS) $(LDFLAGS)
  224. XX!     chmem =150000 flex
  225. XX  
  226. XX  first_flex:
  227. XX      cp initscan.c scan.c
  228. X/
  229. Xecho x - flex.skel_cdif
  230. Xsed '/^X/s///' > flex.skel_cdif << '/'
  231. XX*** Src_2.1/flex.skel    Thu Jun 28 00:19:20 1989
  232. XX--- flex.skel    Thu Jul  2 22:18:31 1989
  233. XX***************
  234. XX*** 28,34 ****
  235. XX   * is returned in "result".
  236. XX   */
  237. XX  #define YY_INPUT(buf,result,max_size) \
  238. XX!     if ( (result = read( fileno(yyin), buf, max_size )) < 0 ) \
  239. XX          YY_FATAL_ERROR( "read() in flex scanner failed" );
  240. XX  #define YY_NULL 0
  241. XX  #define yyterminate() return ( YY_NULL )
  242. XX--- 28,34 ----
  243. XX   * is returned in "result".
  244. XX   */
  245. XX  #define YY_INPUT(buf,result,max_size) \
  246. XX!     if ( (result = fread( buf,1, max_size, yyin )) < 0 ) \
  247. XX          YY_FATAL_ERROR( "read() in flex scanner failed" );
  248. XX  #define YY_NULL 0
  249. XX  #define yyterminate() return ( YY_NULL )
  250. X/
  251. Xecho x - flexdef.h_cdif
  252. Xsed '/^X/s///' > flexdef.h_cdif << '/'
  253. XX*** Src_2.1/flexdef.h    Thu Jun 28 00:43:27 1989
  254. XX--- flexdef.h    Thu Jul  3 02:45:50 1989
  255. XX***************
  256. XX*** 26,31 ****
  257. XX--- 26,40 ----
  258. XX  
  259. XX  /* @(#) $Header: flexdef.h,v 2.0 89/06/20 15:49:50 vern Locked $ (LBL) */
  260. XX  
  261. XX+ #ifdef ATARI
  262. XX+ #define SYS_V
  263. XX+ #define abs(x) ((x) < 0 ? -(x) : (x))
  264. XX+ #define SHORT_FILE_NAMES
  265. XX+ #ifdef TURBO
  266. XX+ #define SHORT_EXTERNAL_NAMES
  267. XX+ #endif
  268. XX+ #endif
  269. XX+ 
  270. XX  #ifndef FILE
  271. XX  #include <stdio.h>
  272. XX  #endif
  273. XX***************
  274. XX*** 41,47 ****
  275. XX  #endif
  276. XX  
  277. XX  #ifndef VMS
  278. XX! char *memset();
  279. XX  #else
  280. XX  /* memset is needed for old versions of the VMS C runtime library */
  281. XX  #define memset(s, c, n) \
  282. XX--- 50,58 ----
  283. XX  #endif
  284. XX  
  285. XX  #ifndef VMS
  286. XX! #ifndef ATARI && TURBO
  287. XX! char *memset();
  288. XX! #endif
  289. XX  #else
  290. XX  /* memset is needed for old versions of the VMS C runtime library */
  291. XX  #define memset(s, c, n) \
  292. XX***************
  293. XX*** 81,91 ****
  294. XX--- 92,129 ----
  295. XX  #define true 1
  296. XX  #define false 0
  297. XX  
  298. XX+ #ifdef ATARI
  299. XX+ #define DEFAULT_SKELETON_FILE "D:\\include\\flexskel"
  300. XX+ #endif
  301. XX+ 
  302. XX  
  303. XX  #ifndef DEFAULT_SKELETON_FILE
  304. XX  #define DEFAULT_SKELETON_FILE "flex.skel"
  305. XX  #endif
  306. XX  
  307. XX+ #ifdef SHORT_EXTERNAL_NAMES
  308. XX+ /* avoid long external names that are ambiguous within the first 8 characters */
  309. XX+ #define current_mns                 c__mns
  310. XX+ #define current_max_rules           c__max_rules
  311. XX+ #define current_max_state_type      c__max_state_type
  312. XX+ #define current_max_scs             c__max_scs
  313. XX+ #define current_max_dfa_size        c__max__size
  314. XX+ #define current_max_xpairs          c__max_xpairs
  315. XX+ #define current_max_template_xpairs c__max_template_xpairs
  316. XX+ #define current_max_dfas            c__max_dfas
  317. XX+ #define current_maxccls             c__maxccles
  318. XX+ #define current_max_ccl_tbl_size    c__max_ccl_tbl_size
  319. XX+ #define indent_puts                 ind_puts
  320. XX+ #define indent_put2s                ind_put2s
  321. XX+ #define gen_next_compressed_state   gen_n_comressed_state
  322. XX+ #define gen_next_match              gen_n_match
  323. XX+ #define gen_next_state              gen_n_state
  324. XX+ #define variable_trailing_context_rules  var_tr_context_rules
  325. XX+ #define variable_trailing_rule           var_tr_rule
  326. XX+ #define backtrack_report            backtr_report
  327. XX+ #define backtrack_file              backtr_file
  328. XX+ #endif
  329. XX+ 
  330. XX  /* special chk[] values marking the slots taking by end-of-buffer and action
  331. XX   * numbers
  332. XX   */
  333. XX***************
  334. XX*** 305,311 ****
  335. XX      int int_val;
  336. XX      } ;
  337. XX  
  338. XX! typedef struct hash_entry *hash_table[];
  339. XX  
  340. XX  #define NAME_TABLE_HASH_SIZE 101
  341. XX  #define START_COND_HASH_SIZE 101
  342. XX--- 343,349 ----
  343. XX      int int_val;
  344. XX      } ;
  345. XX  
  346. XX! typedef struct hash_entry **hash_table;
  347. XX  
  348. XX  #define NAME_TABLE_HASH_SIZE 101
  349. XX  #define START_COND_HASH_SIZE 101
  350. XX***************
  351. XX*** 372,378 ****
  352. XX  extern int datapos, dataline, linenum;
  353. XX  extern FILE *skelfile, *yyin, *temp_action_file, *backtrack_file;
  354. XX  extern char *infilename;
  355. XX! extern char action_file_name[];
  356. XX  
  357. XX  
  358. XX  /* variables for stack of states having only one out-transition:
  359. XX--- 410,416 ----
  360. XX  extern int datapos, dataline, linenum;
  361. XX  extern FILE *skelfile, *yyin, *temp_action_file, *backtrack_file;
  362. XX  extern char *infilename;
  363. XX! extern char *action_file_name;
  364. XX  
  365. XX  
  366. XX  /* variables for stack of states having only one out-transition:
  367. X/
  368. Xecho x - main.c_cdiff
  369. Xsed '/^X/s///' > main.c_cdiff << '/'
  370. XX*** Src_2.1/main.c    Thu Jun 28 00:30:39 1989
  371. XX--- main.c    Thu Jul  3 02:27:47 1989
  372. XX***************
  373. XX*** 81,96 ****
  374. XX  FILE *temp_action_file;
  375. XX  FILE *backtrack_file;
  376. XX  int end_of_buffer_state;
  377. XX! #ifndef SHORT_FILE_NAMES
  378. XX! char action_file_name[] = "/tmp/flexXXXXXX";
  379. XX! #else
  380. XX! char action_file_name[] = "flexXXXXXX.tmp";
  381. XX! #endif
  382. XX! 
  383. XX  #ifndef SHORT_FILE_NAMES
  384. XX  static char outfile[] = "lex.yy.c";
  385. XX  #else
  386. XX! static char outfile[] = "lexyy.c";
  387. XX  #endif
  388. XX  static int outfile_created = 0;
  389. XX  
  390. XX--- 81,91 ----
  391. XX  FILE *temp_action_file;
  392. XX  FILE *backtrack_file;
  393. XX  int end_of_buffer_state;
  394. XX! char *action_file_name;
  395. XX  #ifndef SHORT_FILE_NAMES
  396. XX  static char outfile[] = "lex.yy.c";
  397. XX  #else
  398. XX! static char outfile[] = "lex_yy.c";
  399. XX  #endif
  400. XX  static int outfile_created = 0;
  401. XX  
  402. XX***************
  403. XX*** 328,333 ****
  404. XX--- 323,329 ----
  405. XX      {
  406. XX      int i, sawcmpflag, use_stdout;
  407. XX      char *arg, *skelname = NULL, *flex_gettime(), clower(), *mktemp();
  408. XX+     char *tmp_action =(char *)0, *malloc();
  409. XX  
  410. XX      printstats = syntaxerror = trace = spprdflt = interactive = caseins = false;
  411. XX      backtrack_report = performance_report = ddebug = fulltbl = fullspd = false;
  412. XX***************
  413. XX*** 349,354 ****
  414. XX--- 345,355 ----
  415. XX      for ( i = 1; arg[i] != '\0'; ++i )
  416. XX          switch ( arg[i] )
  417. XX          {
  418. XX+         case 'a':
  419. XX+             if ( i != 1 )
  420. XX+             flexerror( "-a flag must be given separately" );
  421. XX+             tmp_action = &arg[i+1];
  422. XX+             goto get_next_arg;
  423. XX          case 'b':
  424. XX              backtrack_report = true;
  425. XX              break;
  426. XX***************
  427. XX*** 445,452 ****
  428. XX              printstats = true;
  429. XX              break;
  430. XX  
  431. XX!         default:
  432. XX!             lerrif( "unknown flag %c", (int) arg[i] );
  433. XX              break;
  434. XX          }
  435. XX  
  436. XX--- 446,458 ----
  437. XX              printstats = true;
  438. XX              break;
  439. XX  
  440. XX!         case '?':
  441. XX!             flexinfo(0);
  442. XX!             break;
  443. XX! 
  444. XX!         default:
  445. XX!             fprintf(stderr,"flex : unknown flag %c\n", (int) arg[i] );
  446. XX!             flexinfo(1);
  447. XX              break;
  448. XX          }
  449. XX  
  450. XX***************
  451. XX*** 454,459 ****
  452. XX--- 460,493 ----
  453. XX      ;
  454. XX      }
  455. XX  
  456. XX+ 
  457. XX+ /* if you change the default tmp file names don't forget to change the
  458. XX+    initialization for i, too !
  459. XX+    
  460. XX+ */
  461. XX+ #ifndef SHORT_FILE_NAMES
  462. XX+     i = 10;
  463. XX+     if (!tmp_action) i += 5;
  464. XX+ #else
  465. XX+     i = 12;
  466. XX+ #endif
  467. XX+     if (tmp_action) 
  468. XX+         i += strlen(tmp_action) + 1;
  469. XX+     if((action_file_name = malloc(i+1)) == (char *)0)
  470. XX+         flexerror("No memory for action_file_name");
  471. XX+     *action_file_name = (char) NULL;
  472. XX+     if (tmp_action) 
  473. XX+         strcat(action_file_name,tmp_action);
  474. XX+ #ifndef SHORT_FILE_NAMES
  475. XX+     else
  476. XX+         strcat(action_file_name,"/tmp");
  477. XX+     strcat(action_file_name,"/flexXXXXXX");
  478. XX+ #else
  479. XX+     if (tmp_action)
  480. XX+         strcat(action_file_name,"/");
  481. XX+     strcat(action_file_name,"flexXXXX.tmp");
  482. XX+ #endif
  483. XX+     
  484. XX      if ( (fulltbl || fullspd) && usemecs )
  485. XX      flexerror( "full table and -cm don't make sense together" );
  486. XX  
  487. XX***************
  488. XX*** 520,526 ****
  489. XX      if ( (skelfile = fopen( skelname, "r" )) == NULL )
  490. XX      lerrsf( "can't open skeleton file %s", skelname );
  491. XX  
  492. XX!     (void) mktemp( action_file_name );
  493. XX  
  494. XX      if ( (temp_action_file = fopen( action_file_name, "w" )) == NULL )
  495. XX      lerrsf( "can't open temporary action file %s", action_file_name );
  496. XX--- 554,562 ----
  497. XX      if ( (skelfile = fopen( skelname, "r" )) == NULL )
  498. XX      lerrsf( "can't open skeleton file %s", skelname );
  499. XX  
  500. XX! #ifndef ATARI && LATTICE
  501. XX!     (void) mktemp( action_file_name );
  502. XX! #endif
  503. XX  
  504. XX      if ( (temp_action_file = fopen( action_file_name, "w" )) == NULL )
  505. XX      lerrsf( "can't open temporary action file %s", action_file_name );
  506. XX***************
  507. XX*** 566,571 ****
  508. XX--- 602,640 ----
  509. XX      }
  510. XX  
  511. XX  
  512. XX+ flexinfo(status)
  513. XX+ int status;
  514. XX+ {
  515. XX+    fprintf(stderr,"Syntax  :  FLEX  inp_file\n");
  516. XX+    fprintf(stderr,"Function: fast lexical analyzer generator  V%s\n",flex_version);
  517. XX+    fprintf(stderr,"Options : a dir_path  : directory path for temporary files\n");
  518. XX+    fprintf(stderr,"    - b  : generate backtracking information to lex.backtrack\n");
  519. XX+    fprintf(stderr,"    - c  : compressed table, no equiv., no meta equiv.classes\n");
  520. XX+    fprintf(stderr,"       e : equivalence classes\n");
  521. XX+    fprintf(stderr,"       F : fast table\n");
  522. XX+    fprintf(stderr,"      |f : full table\n");
  523. XX+    fprintf(stderr,"      |m : meta equivalence classes\n");
  524. XX+    fprintf(stderr,"    - d  : generate debugging scanner\n");
  525. XX+    fprintf(stderr,"    - F  : fast table\n");
  526. XX+    fprintf(stderr,"    - f  : full (not compressed) table\n");
  527. XX+    fprintf(stderr,"    - I  : generate interactive scanner\n");
  528. XX+    fprintf(stderr,"    - i  : generate case-insensitive scanner\n");
  529. XX+    fprintf(stderr,"    - L  : supress #line directives\n");
  530. XX+ /*   fprintf(stderr,"    - n hexnum : generate scanner using <hexnum> as newline char.\n");*/
  531. XX+    fprintf(stderr,"    - p  : generate performance report to stderr\n");
  532. XX+    fprintf(stderr,"    - S skeleton_path : file path for skeleton file\n");
  533. XX+    fprintf(stderr,"    - s  : suppress echo of unmatched scanner input to stdout\n");
  534. XX+    fprintf(stderr,"    - T  : run flex in trace mode\n");
  535. XX+ #ifdef ATARI
  536. XX+    fprintf(stderr,"    - t  : place result on stdout instead of lex_yy.c\n");
  537. XX+ #else
  538. XX+    fprintf(stderr,"    - t  : place result on stdout instead of lex.yy.c\n");
  539. XX+ #endif
  540. XX+    fprintf(stderr,"    - v  : print statistics of generated scanner\n");
  541. XX+    fprintf(stderr,"     default =  -cem\n");
  542. XX+    exit(status);
  543. XX+ }
  544. XX+ 
  545. XX  /* readin - read in the rules section of the input file(s)
  546. XX   *
  547. XX   * synopsis
  548. X/
  549. Xecho x - scan.l_cdiff
  550. Xsed '/^X/s///' > scan.l_cdiff << '/'
  551. XX*** Src_2.1/scan.l    Thu Jun 30 19:42:00 1989
  552. XX--- scan.l    Thu Jul  2 22:19:26 1989
  553. XX***************
  554. XX*** 125,132 ****
  555. XX  
  556. XX  {SCNAME}        RETURNNAME;
  557. XX  ^{OPTWS}\n        ++linenum; /* allows blank lines in section 1 */
  558. XX! \n            ++linenum; return ( '\n' );
  559. XX! .            synerr( "illegal character" ); BEGIN(RECOVER);
  560. XX  
  561. XX  
  562. XX  <C_COMMENT>"*/"        ECHO; BEGIN(0);
  563. XX--- 125,136 ----
  564. XX  
  565. XX  {SCNAME}        RETURNNAME;
  566. XX  ^{OPTWS}\n        ++linenum; /* allows blank lines in section 1 */
  567. XX! {OPTWS}\n        ++linenum; return ( '\n' );
  568. XX! .            {
  569. XX!             synerr( "illegal character" );
  570. XX!             fprintf(stderr,"Char : $%x\n",yytext[yyleng-1]);
  571. XX!             BEGIN(RECOVER);
  572. XX!             }
  573. XX  
  574. XX  
  575. XX  <C_COMMENT>"*/"        ECHO; BEGIN(0);
  576. XX***************
  577. XX*** 206,212 ****
  578. XX  <SECT2>^{OPTWS}\n    ++linenum; /* allow blank lines in section 2 */
  579. XX  
  580. XX      /* this horrible mess of a rule matches indented lines which
  581. XX!      * do not contain "/*".  We need to make the distinction because
  582. XX       * otherwise this rule will be taken instead of the rule which
  583. XX       * matches the beginning of comments like this one
  584. XX       */
  585. XX--- 210,216 ----
  586. XX  <SECT2>^{OPTWS}\n    ++linenum; /* allow blank lines in section 2 */
  587. XX  
  588. XX      /* this horrible mess of a rule matches indented lines which
  589. XX!      * do not contain '/','*'.  We need to make the distinction because
  590. XX       * otherwise this rule will be taken instead of the rule which
  591. XX       * matches the beginning of comments like this one
  592. XX       */
  593. X/
  594. Xecho x - Makefile.tos
  595. Xsed '/^X/s///' > Makefile.tos << '/'
  596. XX# make file for "flex" tool
  597. XX
  598. XX# @(#) $Header: Makefile,v 2.3 89/06/20 17:27:12 vern Exp $ (LBL)
  599. XX
  600. XX# Porting considerations:
  601. XX#
  602. XX#    For System V Unix machines, add -DSYS_V to CFLAGS.
  603. XX#    For Vax/VMS, add -DSYS_V to CFLAGS.
  604. XX#    For MS-DOS, add "-DMS_DOS -DSYS_V" to CFLAGS.  Create \tmp if not present.
  605. XX#         You will also want to rename flex.skel to something with a three
  606. XX#         character extension, change SKELETON_FILE below appropriately,
  607. XX#    For Amiga, add "-DAMIGA -DSYS_V" to CFLAGS.
  608. XX#
  609. XX# A long time ago, flex was successfully built using Microsoft C and
  610. XX# the following options: /AL, /stack:10000, -LARGE, -Ml, -Mt128, -DSYS_V
  611. XX
  612. XX
  613. XX# the first time around use "make first_flex"
  614. XX
  615. XX# The following definitions must be set according to your compiler -
  616. XX# examples for a Lattice Compiler with GST assembler and TURBO C with
  617. XX# assembler are provided below and must just be updated (don't forget to
  618. XX# update the linker argument extension files (*.lnk,*.tlk), too) :
  619. XX#
  620. XX#CCPATH  = path to compiler directory without trailing \
  621. XX#CHPATH  = path to header files without trailing \
  622. XX#CC      = filename of the compiler
  623. XX#CFLAGS  = compiler option flags
  624. XX#CIEXT   = extension of C sources that should be used for input filenames
  625. XX#ASMPATH = path to assembler directory without trailing \
  626. XX#ASM     = filename of the assembler
  627. XX#AFLAGS  = assembler option flags
  628. XX#AIEXT   = extension of assembler sources that should be used for assembler
  629. XX#          input filenames
  630. XX#AEXT    = general assembler filename extension
  631. XX#LNKPATH = path to linker directory without trailing \
  632. XX#LINK    = filename of the linker
  633. XX#LFLAG0  = first option (full pathname of C startupcode) 
  634. XX#LFLAG1  = further options + option flag for argument extension filename
  635. XX#LFLAG2  = further options + option flag for output-filename 
  636. XX#LNKEXT  = extension of linker argument extension file
  637. XX#OIEXT   = extension of objects that should be used for linker input files
  638. XX#OEXT    = general object file extension
  639. XX
  640. XX# Lattice definitions
  641. XXCCPATH  = d:\latt
  642. XXCHPATH  = d:\latt\include
  643. XXCC      = lc.ttp
  644. XXCFLAGS  = -h -n -cw -cc -i$(CHPATH)\ -g$(CCPATH)\ -dLATTICE -dATARI
  645. XXCIEXT   =
  646. XXASMPATH = d:\gst
  647. XXASM     = assem.ttp
  648. XXAFLAGS  = -nolist -errors errors.out
  649. XXAIEXT   =
  650. XXAEXT    = .asm
  651. XXLNKPATH = d:\gst
  652. XXLINK    = ld.ttp
  653. XXLFLAG0  =
  654. XXLFLAG1  = -with 
  655. XXLFLAG2  = -nolist -sec -mem 200 -prog 
  656. XXLNKEXT  = .lnk
  657. XXOIEXT   =
  658. XXOEXT    = .bin
  659. XX
  660. XX# Turbo definitions
  661. XX#CCPATH  = d:\turbo
  662. XX#CHPATH  = d:\turbo\include
  663. XX#CC      = tcc.prg
  664. XX#CFLAGS  = -GJMPRZ -H=$(CHPATH)\ -w- -DTURBO -DATARI
  665. XX#CIEXT   = .c
  666. XX#ASMPATH = d:\turbo
  667. XX#ASM     = mas.prg
  668. XX#AFLAGS  =
  669. XX#AIEXT   = .s
  670. XX#AEXT    = .s
  671. XX#LNKPATH = d:\turbo
  672. XX#LINK    = tlink.ttp
  673. XX#LFLAG0  = $(LNKPATH)\lib\tcstart.o
  674. XX#LFLAG1  = -I=
  675. XX#LFLAG2  = -O=
  676. XX#LNKEXT  = .tlk
  677. XX#OIEXT   = .o
  678. XX#OEXT    = .o
  679. XX
  680. XX# Other definitions
  681. XX# (not used for Atari because of short argument string - defined in flexdef.h
  682. XX
  683. XXSKELETON_DIR = /usr/lib
  684. XXSKELETON_FILE = flex.skel
  685. XXSKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_DIR)/$(SKELETON_FILE)\"
  686. XX
  687. XX
  688. XXFLEX       = d:\etc\flex.ttp
  689. XXFLEX_FLAGS = -is
  690. XXYACC       = d:\etc\yacc.ttp
  691. XXRENAME     = d:\bin\rename
  692. XXDEL        = d:\bin\del
  693. XX
  694. XX# Internal definitions
  695. XXLNK     = $(LNKPATH)\$(LINK)
  696. XX
  697. XXFLEXOBJS = \
  698. XX    ccl$(OEXT) \
  699. XX    dfa$(OEXT) \
  700. XX    ecs$(OEXT) \
  701. XX    gen$(OEXT) \
  702. XX    main$(OEXT) \
  703. XX    misc$(OEXT) \
  704. XX    nfa$(OEXT) \
  705. XX    parse$(OEXT) \
  706. XX    scan$(OEXT) \
  707. XX    sym$(OEXT) \
  708. XX    tblcmp$(OEXT) \
  709. XX    yylex$(OEXT)
  710. XX
  711. XXFLEX_C_SOURCES = \
  712. XX    ccl.c \
  713. XX    dfa.c \
  714. XX    ecs.c \
  715. XX    gen.c \
  716. XX    main.c \
  717. XX    misc.c \
  718. XX    nfa.c \
  719. XX    parse.c \
  720. XX    scan.c \
  721. XX    sym.c \
  722. XX    tblcmp.c \
  723. XX    yylex.c
  724. XX
  725. XXflex : $(FLEXOBJS)
  726. XX     $(LNK) $(LFLAG0) $(LFLAG1)flex$(LNKEXT) $(LFLAG2)flex.ttp
  727. XX
  728. XXfirst_flex:
  729. XX    cp initscan.c scan.c
  730. XX    make $(MFLAGS) flex
  731. XX
  732. XXparse.h parse.c : parse.y
  733. XX    $(YACC)   -d parse.y
  734. XX    $(DEL)    parse.c
  735. XX    $(RENAME) y_tab.c parse.c
  736. XX    $(DEL)    parse.h
  737. XX    $(RENAME) y_tab.h parse.h
  738. XX
  739. XXscan.c : scan.l
  740. XX    $(FLEX)   $(FLEX_FLAGS) scan.l
  741. XX    $(RENAME) lex_yy.c scan.c
  742. XX
  743. XXscan$(OEXT) : scan.c parse.h flexdef.h
  744. XX     $(CCPATH)\$(CC) $(CFLAGS) scan$(CIEXT)
  745. XX
  746. XXmain$(OEXT) : main.c flexdef.h
  747. XX     $(CCPATH)\$(CC) $(CFLAGS)  main$(CIEXT)
  748. XX
  749. XXccl$(OEXT) : ccl.c flexdef.h 
  750. XX     $(CCPATH)\$(CC) $(CFLAGS)  ccl$(CIEXT)
  751. XX
  752. XXdfa$(OEXT) : dfa.c flexdef.h
  753. XX     $(CCPATH)\$(CC) $(CFLAGS)  dfa$(CIEXT)
  754. XX
  755. XXecs$(OEXT) : ecs.c flexdef.h
  756. XX     $(CCPATH)\$(CC) $(CFLAGS)  ecs$(CIEXT)
  757. XX
  758. XXgen$(OEXT) : gen.c flexdef.h
  759. XX     $(CCPATH)\$(CC) $(CFLAGS)  gen$(CIEXT)
  760. XX
  761. XXmisc$(OEXT) : misc.c flexdef.h
  762. XX     $(CCPATH)\$(CC) $(CFLAGS)  misc$(CIEXT)
  763. XX
  764. XXnfa$(OEXT) : nfa.c flexdef.h
  765. XX     $(CCPATH)\$(CC) $(CFLAGS)  nfa$(CIEXT)
  766. XX
  767. XXparse$(OEXT) : parse.c flexdef.h
  768. XX     $(CCPATH)\$(CC) $(CFLAGS)  parse$(CIEXT)
  769. XX
  770. XXsym$(OEXT) : sym.c flexdef.h
  771. XX     $(CCPATH)\$(CC) $(CFLAGS)  sym$(CIEXT)
  772. XX
  773. XXtblcmp$(OEXT) : tblcmp.c flexdef.h
  774. XX     $(CCPATH)\$(CC) $(CFLAGS)  tblcmp$(CIEXT)
  775. XX
  776. XXyylex$(OEXT) : yylex.c flexdef.h 
  777. XX     $(CCPATH)\$(CC) $(CFLAGS)  yylex$(CIEXT)
  778. XX
  779. XXflex.man : flex.1
  780. XX    nroff -man flex.1 >flex.man
  781. XX
  782. XXlint : $(FLEX_C_SOURCES)
  783. XX    lint $(FLEX_C_SOURCES) > flex.lint
  784. XX
  785. XXdistrib :
  786. XX    mv scan.c initscan.c
  787. XX    chmod 444 initscan.c
  788. XX    $(MAKE) $(MFLAGS) clean
  789. XX
  790. XXclean :
  791. XX    rm -f core errs flex *$(OEXT) parse.c *.lint parse.h flex.man tags
  792. XX
  793. XXtags :
  794. XX    ctags $(FLEX_C_SOURCES)
  795. XX
  796. XXvms :    flex.man
  797. XX    $(MAKE) $(MFLAGS) distrib
  798. XX
  799. XXtest :
  800. XX    $(FLEX) $(FLEX_FLAGS) scan.l
  801. XX    $(RENAME) lex_yy.c scan.ctest
  802. XX    cmp scan.c scan.ctest
  803. XX
  804. X/
  805. Xecho x - Readme2
  806. Xsed '/^X/s///' > Readme2 << '/'
  807. XXThe changes:                                                  (1.7.89 RAL)
  808. XX
  809. XX - Bug fix: The original flex didn't like trailing spaces in exclusive start
  810. XX     condition lists ! If you add an trailing space to line 68 in scan.l
  811. XX     
  812. XX     "%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE "
  813. XX     
  814. XX     you get a misleading error message: 
  815. XX     
  816. XX     "Syntax error at line 69: bad start condition list"
  817. XX     
  818. XX     This bug can either be fixed in parse.y or in scan.l . I have chosen the
  819. XX     last because there the fix is minimal: Just change the rule (line 128)
  820. XX     
  821. XX      "\n"    to   "{OPTWS}\n"
  822. XX      
  823. XX - Enhancements:
  824. XX    - new option "-?" that provides some help information about the other
  825. XX      flags (main.c)
  826. XX    - new option "-aTMPPATH" that allows a redefinition of the standard
  827. XX      path for the temporary file (this might be rather large >200k if 
  828. XX      F,f options are selected). (main.c, flexdef.h (l.376))
  829. XX    - hexdump of illegal characters -- this proved to be a useful debugging
  830. XX      tool especialy if invisible control characters occur which weren't
  831. XX      covered by the rules. (scan.l  fprintf statement line 129,...)
  832. XX      
  833. XX - Patches due to TOS
  834. XX    - General: TOS uses CR,LF as end of line char., Flex wants only a single
  835. XX      LF as EOL char. Therefore all I/O must be translated using f* calls.
  836. XX      This is done everywhere besides the YY_INPUT macro (flex.skel (scan.c),
  837. XX      line 31) that uses a low level 'read'. This should be definitly changed
  838. XX      to fread, so that all I/O calls occur on the same level.
  839. XX    - the short action_file_name has been "flexXXXXXX.tmp", but that's too 
  840. XX      much for TOS,MSDOS ! I changed it to "flexXXXX.tmp" in main.c (patch
  841. XX      covered by the -a option additions)
  842. XX    - some compilers don't like external names that are ambiguous within
  843. XX      the first 8 characters. I defined macros that change all these long
  844. XX      external names to names that are unique within the first 8 characters.
  845. XX      Just define SHORT_EXTERNAL_NAMES to use this feature (flexdef.h)
  846. XX    - some statement changes that some compiler don't like:
  847. XX      typedef *xxx[]  -> typedef **xxx       (flexdef.h.,l.308)
  848. XX      "/*" -> '/','*' within a comment in (scan.l, l.209)
  849. XX    - changed short "lexyy.c" to "lex_yy.c" what's more similar to the unix
  850. XX      "lex.yy.c" (main.c).
  851. XX    - a few further really compiler dependent changes provided with
  852. XX      #ifdef ATARI && LATTICE res. TURBO braces.
  853. XX      
  854. XX - Additional TOS only files
  855. XX    - Makefile.tos: Common makefile for all TOS compilers. If you add further
  856. XX      ones please email me the new makefile.
  857. XX    - flex.lnk: Lattice - GST linker argument extension file
  858. XX    - flex.tlk: Turbo linker argument extension file
  859. XX      
  860. XX    
  861. XXAdditional remarks:
  862. XX 
  863. XXI didn't add a new initscan.c (= flex -ist scan.l). The current one is good
  864. XXenough for a first compilation. With this first version of flex you can
  865. XXrebuild your own scan.c and the final flex version !
  866. XX
  867. XXMinix ST :
  868. XX  - I had to "chmem =70000 cv" (>50000) to get flex linked
  869. XX  - 'memset' (PC 1.3, EFTH40,...) is necessary
  870. XX  - chmem =90000 flex may be sufficient
  871. XX  
  872. XXMinix PC :
  873. XX  It should be possible to port Flex to Minix PC. The current sizes of flex
  874. XX  are:
  875. XX                        Minix ST (ACK)    Lattice (TOS)    Turbo (TOS)
  876. XX       
  877. XX       size               75300             83305             57957
  878. XX       compilation time      22'               15'             3'40"
  879. XX       flex -is scan.l     1'49"               43"               30"
  880. XX       
  881. XX  The Minix ST size includes the bad generated code using only a subset of
  882. XX  the 68000 commands, long addresses only and a huge relocation table.
  883. XX  Therefore the PC size will be <64 k ! More serious is the fact that I had
  884. XX  to chmem =90000 flex to get scan.l converted to scan.c . But I never saw
  885. XX  a more complex lex source than scan.l -- so it should be possible to
  886. XX  reduce some array sizes without limitation for all day usage.
  887. XX  
  888. XX  No one volunteered yet for a Minix PC port -- but if someone will try it
  889. XX  I would provide him with a new scan.c and some hints.
  890. XX  
  891. XXTOS: 
  892. XX  Don't forget to adapt the flexskel path within flexdef.h !
  893. XX
  894. XX
  895. X/
  896. Xecho x - flex.lnk
  897. Xsed '/^X/s///' > flex.lnk << '/'
  898. XX*
  899. XX*
  900. XX*  linker control file for flex.ttp
  901. XX*
  902. XX*
  903. XX*
  904. XXINPUT   d:\latt\lib\startup.bin
  905. XX*
  906. XXINPUT ccl.bin
  907. XXINPUT dfa.bin
  908. XXINPUT ecs.bin
  909. XXINPUT gen.bin
  910. XXINPUT misc.bin
  911. XXINPUT nfa.bin
  912. XXINPUT parse.bin
  913. XXINPUT sym.bin
  914. XXINPUT tblcmp.bin
  915. XXINPUT main.bin
  916. XXINPUT yylex.bin
  917. XXINPUT scan.bin
  918. XX*
  919. XXLIBRARY d:\latt\lib\clib.bin
  920. XX
  921. X/
  922. Xecho x - flex.tlk
  923. Xsed '/^X/s///' > flex.tlk << '/'
  924. XXccl.o
  925. XXdfa.o
  926. XXecs.o
  927. XXgen.o
  928. XXmisc.o
  929. XXnfa.o
  930. XXparse.o
  931. XXsym.o
  932. XXtblcmp.o
  933. XXyylex.o
  934. XXmain.o
  935. XXscan.o
  936. XXd:\turbo\lib\tcstdlib.lib   ; standard lib
  937. XXd:\turbo\lib\tcextlib.lib   ; extended lib
  938. XXd:\turbo\lib\tctoslib.lib   ; TOS lib
  939. XXd:\turbo\lib\tcgemlib.lib   ; AES and VDI lib
  940. XX-S=200000
  941. X/
  942. END_OF_FILE
  943. if test 29474 -ne `wc -c <'MISC/Atari.patches'`; then
  944.     echo shar: \"'MISC/Atari.patches'\" unpacked with wrong size!
  945. fi
  946. # end of 'MISC/Atari.patches'
  947. fi
  948. if test -f 'flexdef.h' -a "${1}" != "-c" ; then 
  949.   echo shar: Will not clobber existing file \"'flexdef.h'\"
  950. else
  951. echo shar: Extracting \"'flexdef.h'\" \(28965 characters\)
  952. sed "s/^X//" >'flexdef.h' <<'END_OF_FILE'
  953. X/* flexdef - definitions file for flex */
  954. X
  955. X/*-
  956. X * Copyright (c) 1990 The Regents of the University of California.
  957. X * All rights reserved.
  958. X *
  959. X * This code is derived from software contributed to Berkeley by
  960. X * Vern Paxson.
  961. X * 
  962. X * The United States Government has rights in this work pursuant
  963. X * to contract no. DE-AC03-76SF00098 between the United States
  964. X * Department of Energy and the University of California.
  965. X *
  966. X * Redistribution and use in source and binary forms are permitted provided
  967. X * that: (1) source distributions retain this entire copyright notice and
  968. X * comment, and (2) distributions including binaries display the following
  969. X * acknowledgement:  ``This product includes software developed by the
  970. X * University of California, Berkeley and its contributors'' in the
  971. X * documentation or other materials provided with the distribution and in
  972. X * all advertising materials mentioning features or use of this software.
  973. X * Neither the name of the University nor the names of its contributors may
  974. X * be used to endorse or promote products derived from this software without
  975. X * specific prior written permission.
  976. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  977. X * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  978. X * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  979. X */
  980. X
  981. X/* @(#) $Header: WPL:Generators/flex-2.3/RCS/flexdef.h,v 1.2 90/07/15 01:17:09 loftus Exp $ (LBL) */
  982. X
  983. X#ifndef FILE
  984. X#include <stdio.h>
  985. X#endif
  986. X
  987. X/* always be prepared to generate an 8-bit scanner */
  988. X#define FLEX_8_BIT_CHARS
  989. X
  990. X#ifdef FLEX_8_BIT_CHARS
  991. X#define CSIZE 256
  992. X#define Char unsigned char
  993. X#else
  994. X#define Char char
  995. X#define CSIZE 128
  996. X#endif
  997. X
  998. X/* size of input alphabet - should be size of ASCII set */
  999. X#ifndef DEFAULT_CSIZE
  1000. X#define DEFAULT_CSIZE 128
  1001. X#endif
  1002. X
  1003. X#ifndef PROTO
  1004. X#ifdef __STDC__
  1005. X#define PROTO(proto) proto
  1006. X#else
  1007. X#define PROTO(proto) ()
  1008. X#endif
  1009. X#endif
  1010. X
  1011. X
  1012. X#ifdef USG
  1013. X#define SYS_V
  1014. X#endif
  1015. X
  1016. X#ifdef SYS_V
  1017. X#include <string.h>
  1018. X#else
  1019. X
  1020. X#include <strings.h>
  1021. X#ifdef lint
  1022. Xchar *sprintf(); /* keep lint happy */
  1023. X#endif
  1024. X#ifdef SCO_UNIX
  1025. Xvoid *memset();
  1026. X#else
  1027. Xchar *memset();
  1028. X#endif
  1029. X#endif
  1030. X
  1031. X#ifdef AMIGA
  1032. X#define bzero(s, n) setmem((char *)(s), n, '\0')
  1033. X#define DEFAULT_SKELETON_FILE "s:flex.skel"
  1034. X#ifndef abs
  1035. X#define abs(x) ((x) < 0 ? -(x) : (x))
  1036. X#endif
  1037. X#else
  1038. X#define bzero(s, n) (void) memset((char *)(s), '\0', n)
  1039. X#endif
  1040. X
  1041. X#ifdef VMS
  1042. X#define unlink delete
  1043. X#define SHORT_FILE_NAMES
  1044. X#endif
  1045. X
  1046. X#ifndef AMIGA
  1047. Xchar *malloc(), *realloc();
  1048. X#endif
  1049. X
  1050. X
  1051. X/* maximum line length we'll have to deal with */
  1052. X#define MAXLINE BUFSIZ
  1053. X
  1054. X/* maximum size of file name */
  1055. X#define FILENAMESIZE 1024
  1056. X
  1057. X#ifndef min
  1058. X#define min(x,y) ((x) < (y) ? (x) : (y))
  1059. X#endif
  1060. X#ifndef max
  1061. X#define max(x,y) ((x) > (y) ? (x) : (y))
  1062. X#endif
  1063. X
  1064. X#ifdef MS_DOS
  1065. X#ifndef abs
  1066. X#define abs(x) ((x) < 0 ? -(x) : (x))
  1067. X#endif
  1068. X#define SHORT_FILE_NAMES
  1069. X#endif
  1070. X
  1071. X#define true 1
  1072. X#define false 0
  1073. X
  1074. X
  1075. X#ifndef DEFAULT_SKELETON_FILE
  1076. X#define DEFAULT_SKELETON_FILE "flex.skel"
  1077. X#endif
  1078. X
  1079. X/* special chk[] values marking the slots taking by end-of-buffer and action
  1080. X * numbers
  1081. X */
  1082. X#define EOB_POSITION -1
  1083. X#define ACTION_POSITION -2
  1084. X
  1085. X/* number of data items per line for -f output */
  1086. X#define NUMDATAITEMS 10
  1087. X
  1088. X/* number of lines of data in -f output before inserting a blank line for
  1089. X * readability.
  1090. X */
  1091. X#define NUMDATALINES 10
  1092. X
  1093. X/* transition_struct_out() definitions */
  1094. X#define TRANS_STRUCT_PRINT_LENGTH 15
  1095. X
  1096. X/* returns true if an nfa state has an epsilon out-transition slot
  1097. X * that can be used.  This definition is currently not used.
  1098. X */
  1099. X#define FREE_EPSILON(state) \
  1100. X    (transchar[state] == SYM_EPSILON && \
  1101. X     trans2[state] == NO_TRANSITION && \
  1102. X     finalst[state] != state)
  1103. X
  1104. X/* returns true if an nfa state has an epsilon out-transition character
  1105. X * and both slots are free
  1106. X */
  1107. X#define SUPER_FREE_EPSILON(state) \
  1108. X    (transchar[state] == SYM_EPSILON && \
  1109. X     trans1[state] == NO_TRANSITION) \
  1110. X
  1111. X/* maximum number of NFA states that can comprise a DFA state.  It's real
  1112. X * big because if there's a lot of rules, the initial state will have a
  1113. X * huge epsilon closure.
  1114. X */
  1115. X#define INITIAL_MAX_DFA_SIZE 750
  1116. X#define MAX_DFA_SIZE_INCREMENT 750
  1117. X
  1118. X
  1119. X/* a note on the following masks.  They are used to mark accepting numbers
  1120. X * as being special.  As such, they implicitly limit the number of accepting
  1121. X * numbers (i.e., rules) because if there are too many rules the rule numbers
  1122. X * will overload the mask bits.  Fortunately, this limit is \large/ (0x2000 ==
  1123. X * 8192) so unlikely to actually cause any problems.  A check is made in
  1124. X * new_rule() to ensure that this limit is not reached.
  1125. X */
  1126. X
  1127. X/* mask to mark a trailing context accepting number */
  1128. X#define YY_TRAILING_MASK 0x2000
  1129. X
  1130. X/* mask to mark the accepting number of the "head" of a trailing context rule */
  1131. X#define YY_TRAILING_HEAD_MASK 0x4000
  1132. X
  1133. X/* maximum number of rules, as outlined in the above note */
  1134. X#define MAX_RULE (YY_TRAILING_MASK - 1)
  1135. X
  1136. X
  1137. X/* NIL must be 0.  If not, its special meaning when making equivalence classes
  1138. X * (it marks the representative of a given e.c.) will be unidentifiable
  1139. X */
  1140. X#define NIL 0
  1141. X
  1142. X#define JAM -1    /* to mark a missing DFA transition */
  1143. X#define NO_TRANSITION NIL
  1144. X#define UNIQUE -1    /* marks a symbol as an e.c. representative */
  1145. X#define INFINITY -1    /* for x{5,} constructions */
  1146. X
  1147. X#define INITIAL_MAX_CCLS 100    /* max number of unique character classes */
  1148. X#define MAX_CCLS_INCREMENT 100
  1149. X
  1150. X/* size of table holding members of character classes */
  1151. X#define INITIAL_MAX_CCL_TBL_SIZE 500
  1152. X#define MAX_CCL_TBL_SIZE_INCREMENT 250
  1153. X
  1154. X#define INITIAL_MAX_RULES 100    /* default maximum number of rules */
  1155. X#define MAX_RULES_INCREMENT 100
  1156. X
  1157. X#define INITIAL_MNS 2000    /* default maximum number of nfa states */
  1158. X#define MNS_INCREMENT 1000    /* amount to bump above by if it's not enough */
  1159. X
  1160. X#define INITIAL_MAX_DFAS 1000    /* default maximum number of dfa states */
  1161. X#define MAX_DFAS_INCREMENT 1000
  1162. X
  1163. X#define JAMSTATE -32766    /* marks a reference to the state that always jams */
  1164. X
  1165. X/* enough so that if it's subtracted from an NFA state number, the result
  1166. X * is guaranteed to be negative
  1167. X */
  1168. X#define MARKER_DIFFERENCE 32000
  1169. X#define MAXIMUM_MNS 31999
  1170. X
  1171. X/* maximum number of nxt/chk pairs for non-templates */
  1172. X#define INITIAL_MAX_XPAIRS 2000
  1173. X#define MAX_XPAIRS_INCREMENT 2000
  1174. X
  1175. X/* maximum number of nxt/chk pairs needed for templates */
  1176. X#define INITIAL_MAX_TEMPLATE_XPAIRS 2500
  1177. X#define MAX_TEMPLATE_XPAIRS_INCREMENT 2500
  1178. X
  1179. X#define SYM_EPSILON (CSIZE + 1)    /* to mark transitions on the symbol epsilon */
  1180. X
  1181. X#define INITIAL_MAX_SCS 40    /* maximum number of start conditions */
  1182. X#define MAX_SCS_INCREMENT 40    /* amount to bump by if it's not enough */
  1183. X
  1184. X#define ONE_STACK_SIZE 500    /* stack of states with only one out-transition */
  1185. X#define SAME_TRANS -1    /* transition is the same as "default" entry for state */
  1186. X
  1187. X/* the following percentages are used to tune table compression:
  1188. X
  1189. X * the percentage the number of out-transitions a state must be of the
  1190. X * number of equivalence classes in order to be considered for table
  1191. X * compaction by using protos
  1192. X */
  1193. X#define PROTO_SIZE_PERCENTAGE 15
  1194. X
  1195. X/* the percentage the number of homogeneous out-transitions of a state
  1196. X * must be of the number of total out-transitions of the state in order
  1197. X * that the state's transition table is first compared with a potential 
  1198. X * template of the most common out-transition instead of with the first
  1199. X * proto in the proto queue
  1200. X */
  1201. X#define CHECK_COM_PERCENTAGE 50
  1202. X
  1203. X/* the percentage the number of differences between a state's transition
  1204. X * table and the proto it was first compared with must be of the total
  1205. X * number of out-transitions of the state in order to keep the first
  1206. X * proto as a good match and not search any further
  1207. X */
  1208. X#define FIRST_MATCH_DIFF_PERCENTAGE 10
  1209. X
  1210. X/* the percentage the number of differences between a state's transition
  1211. X * table and the most similar proto must be of the state's total number
  1212. X * of out-transitions to use the proto as an acceptable close match
  1213. X */
  1214. X#define ACCEPTABLE_DIFF_PERCENTAGE 50
  1215. X
  1216. X/* the percentage the number of homogeneous out-transitions of a state
  1217. X * must be of the number of total out-transitions of the state in order
  1218. X * to consider making a template from the state
  1219. X */
  1220. X#define TEMPLATE_SAME_PERCENTAGE 60
  1221. X
  1222. X/* the percentage the number of differences between a state's transition
  1223. X * table and the most similar proto must be of the state's total number
  1224. X * of out-transitions to create a new proto from the state
  1225. X */
  1226. X#define NEW_PROTO_DIFF_PERCENTAGE 20
  1227. X
  1228. X/* the percentage the total number of out-transitions of a state must be
  1229. X * of the number of equivalence classes in order to consider trying to
  1230. X * fit the transition table into "holes" inside the nxt/chk table.
  1231. X */
  1232. X#define INTERIOR_FIT_PERCENTAGE 15
  1233. X
  1234. X/* size of region set aside to cache the complete transition table of
  1235. X * protos on the proto queue to enable quick comparisons
  1236. X */
  1237. X#define PROT_SAVE_SIZE 2000
  1238. X
  1239. X#define MSP 50    /* maximum number of saved protos (protos on the proto queue) */
  1240. X
  1241. X/* maximum number of out-transitions a state can have that we'll rummage
  1242. X * around through the interior of the internal fast table looking for a
  1243. X * spot for it
  1244. X */
  1245. X#define MAX_XTIONS_FULL_INTERIOR_FIT 4
  1246. X
  1247. X/* maximum number of rules which will be reported as being associated
  1248. X * with a DFA state
  1249. X */
  1250. X#define MAX_ASSOC_RULES 100
  1251. X
  1252. X/* number that, if used to subscript an array, has a good chance of producing
  1253. X * an error; should be small enough to fit into a short
  1254. X */
  1255. X#define BAD_SUBSCRIPT -32767
  1256. X
  1257. X/* absolute value of largest number that can be stored in a short, with a
  1258. X * bit of slop thrown in for general paranoia.
  1259. X */
  1260. X#define MAX_SHORT 32766
  1261. X
  1262. X
  1263. X/* Declarations for global variables. */
  1264. X
  1265. X/* variables for symbol tables:
  1266. X * sctbl - start-condition symbol table
  1267. X * ndtbl - name-definition symbol table
  1268. X * ccltab - character class text symbol table
  1269. X */
  1270. X
  1271. Xstruct hash_entry
  1272. X    {
  1273. X    struct hash_entry *prev, *next;
  1274. X    char *name;
  1275. X    char *str_val;
  1276. X    int int_val;
  1277. X    } ;
  1278. X
  1279. Xtypedef struct hash_entry *hash_table[];
  1280. X
  1281. X#define NAME_TABLE_HASH_SIZE 101
  1282. X#define START_COND_HASH_SIZE 101
  1283. X#define CCL_HASH_SIZE 101
  1284. X
  1285. Xextern struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE]; 
  1286. Xextern struct hash_entry *sctbl[START_COND_HASH_SIZE];
  1287. Xextern struct hash_entry *ccltab[CCL_HASH_SIZE];
  1288. X
  1289. X
  1290. X/* variables for flags:
  1291. X * printstats - if true (-v), dump statistics
  1292. X * syntaxerror - true if a syntax error has been found
  1293. X * eofseen - true if we've seen an eof in the input file
  1294. X * ddebug - if true (-d), make a "debug" scanner
  1295. X * trace - if true (-T), trace processing
  1296. X * spprdflt - if true (-s), suppress the default rule
  1297. X * interactive - if true (-I), generate an interactive scanner
  1298. X * caseins - if true (-i), generate a case-insensitive scanner
  1299. X * useecs - if true (-Ce flag), use equivalence classes
  1300. X * fulltbl - if true (-Cf flag), don't compress the DFA state table
  1301. X * usemecs - if true (-Cm flag), use meta-equivalence classes
  1302. X * fullspd - if true (-F flag), use Jacobson method of table representation
  1303. X * gen_line_dirs - if true (i.e., no -L flag), generate #line directives
  1304. X * performance_report - if true (i.e., -p flag), generate a report relating
  1305. X *   to scanner performance
  1306. X * backtrack_report - if true (i.e., -b flag), generate "lex.backtrack" file
  1307. X *   listing backtracking states
  1308. X * csize - size of character set for the scanner we're generating;
  1309. X *   128 for 7-bit chars and 256 for 8-bit
  1310. X * yymore_used - if true, yymore() is used in input rules
  1311. X * reject - if true, generate backtracking tables for REJECT macro
  1312. X * real_reject - if true, scanner really uses REJECT (as opposed to just
  1313. X *   having "reject" set for variable trailing context)
  1314. X * continued_action - true if this rule's action is to "fall through" to
  1315. X *   the next rule's action (i.e., the '|' action)
  1316. X * yymore_really_used - has a REALLY_xxx value indicating whether a
  1317. X *   %used or %notused was used with yymore()
  1318. X * reject_really_used - same for REJECT
  1319. X */
  1320. X
  1321. Xextern int printstats, syntaxerror, eofseen, ddebug, trace, spprdflt;
  1322. Xextern int interactive, caseins, useecs, fulltbl, usemecs;
  1323. Xextern int fullspd, gen_line_dirs, performance_report, backtrack_report, csize;
  1324. Xextern int yymore_used, reject, real_reject, continued_action;
  1325. X
  1326. X#define REALLY_NOT_DETERMINED 0
  1327. X#define REALLY_USED 1
  1328. X#define REALLY_NOT_USED 2
  1329. Xextern int yymore_really_used, reject_really_used;
  1330. X
  1331. X
  1332. X/* variables used in the flex input routines:
  1333. X * datapos - characters on current output line
  1334. X * dataline - number of contiguous lines of data in current data
  1335. X *    statement.  Used to generate readable -f output
  1336. X * linenum - current input line number
  1337. X * skelfile - the skeleton file
  1338. X * yyin - input file
  1339. X * temp_action_file - temporary file to hold actions
  1340. X * backtrack_file - file to summarize backtracking states to
  1341. X * infilename - name of input file
  1342. X * action_file_name - name of the temporary file
  1343. X * input_files - array holding names of input files
  1344. X * num_input_files - size of input_files array
  1345. X * program_name - name with which program was invoked 
  1346. X */
  1347. X
  1348. Xextern int datapos, dataline, linenum;
  1349. Xextern FILE *skelfile, *yyin, *temp_action_file, *backtrack_file;
  1350. Xextern char *infilename;
  1351. Xextern char *action_file_name;
  1352. Xextern char **input_files;
  1353. Xextern int num_input_files;
  1354. Xextern char *program_name;
  1355. X
  1356. X
  1357. X/* variables for stack of states having only one out-transition:
  1358. X * onestate - state number
  1359. X * onesym - transition symbol
  1360. X * onenext - target state
  1361. X * onedef - default base entry
  1362. X * onesp - stack pointer
  1363. X */
  1364. X
  1365. Xextern int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE];
  1366. Xextern int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp;
  1367. X
  1368. X
  1369. X/* variables for nfa machine data:
  1370. X * current_mns - current maximum on number of NFA states
  1371. X * num_rules - number of the last accepting state; also is number of
  1372. X *             rules created so far
  1373. X * current_max_rules - current maximum number of rules
  1374. X * lastnfa - last nfa state number created
  1375. X * firstst - physically the first state of a fragment
  1376. X * lastst - last physical state of fragment
  1377. X * finalst - last logical state of fragment
  1378. X * transchar - transition character
  1379. X * trans1 - transition state
  1380. X * trans2 - 2nd transition state for epsilons
  1381. X * accptnum - accepting number
  1382. X * assoc_rule - rule associated with this NFA state (or 0 if none)
  1383. X * state_type - a STATE_xxx type identifying whether the state is part
  1384. X *              of a normal rule, the leading state in a trailing context
  1385. X *              rule (i.e., the state which marks the transition from
  1386. X *              recognizing the text-to-be-matched to the beginning of
  1387. X *              the trailing context), or a subsequent state in a trailing
  1388. X *              context rule
  1389. X * rule_type - a RULE_xxx type identifying whether this a a ho-hum
  1390. X *             normal rule or one which has variable head & trailing
  1391. X *             context
  1392. X * rule_linenum - line number associated with rule
  1393. X */
  1394. X
  1395. Xextern int current_mns, num_rules, current_max_rules, lastnfa;
  1396. Xextern int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2;
  1397. Xextern int *accptnum, *assoc_rule, *state_type, *rule_type, *rule_linenum;
  1398. X
  1399. X/* different types of states; values are useful as masks, as well, for
  1400. X * routines like check_trailing_context()
  1401. X */
  1402. X#define STATE_NORMAL 0x1
  1403. X#define STATE_TRAILING_CONTEXT 0x2
  1404. X
  1405. X/* global holding current type of state we're making */
  1406. X
  1407. Xextern int current_state_type;
  1408. X
  1409. X/* different types of rules */
  1410. X#define RULE_NORMAL 0
  1411. X#define RULE_VARIABLE 1
  1412. X
  1413. X/* true if the input rules include a rule with both variable-length head
  1414. X * and trailing context, false otherwise
  1415. X */
  1416. Xextern int variable_trailing_context_rules;
  1417. X
  1418. X
  1419. X/* variables for protos:
  1420. X * numtemps - number of templates created
  1421. X * numprots - number of protos created
  1422. X * protprev - backlink to a more-recently used proto
  1423. X * protnext - forward link to a less-recently used proto
  1424. X * prottbl - base/def table entry for proto
  1425. X * protcomst - common state of proto
  1426. X * firstprot - number of the most recently used proto
  1427. X * lastprot - number of the least recently used proto
  1428. X * protsave contains the entire state array for protos
  1429. X */
  1430. X
  1431. Xextern int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP];
  1432. Xextern int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE];
  1433. X
  1434. X
  1435. X/* variables for managing equivalence classes:
  1436. X * numecs - number of equivalence classes
  1437. X * nextecm - forward link of Equivalence Class members
  1438. X * ecgroup - class number or backward link of EC members
  1439. X * nummecs - number of meta-equivalence classes (used to compress
  1440. X *   templates)
  1441. X * tecfwd - forward link of meta-equivalence classes members
  1442. X * tecbck - backward link of MEC's
  1443. X * xlation - maps character codes to their translations, or nil if no %t table
  1444. X * num_xlations - number of different xlation values
  1445. X */
  1446. X
  1447. X/* reserve enough room in the equivalence class arrays so that we
  1448. X * can use the CSIZE'th element to hold equivalence class information
  1449. X * for the NUL character.  Later we'll move this information into
  1450. X * the 0th element.
  1451. X */
  1452. Xextern int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs;
  1453. X
  1454. X/* meta-equivalence classes are indexed starting at 1, so it's possible
  1455. X * that they will require positions from 1 .. CSIZE, i.e., CSIZE + 1
  1456. X * slots total (since the arrays are 0-based).  nextecm[] and ecgroup[]
  1457. X * don't require the extra position since they're indexed from 1 .. CSIZE - 1.
  1458. X */
  1459. Xextern int tecfwd[CSIZE + 1], tecbck[CSIZE + 1];
  1460. X
  1461. Xextern int *xlation;
  1462. Xextern int num_xlations;
  1463. X
  1464. X
  1465. X/* variables for start conditions:
  1466. X * lastsc - last start condition created
  1467. X * current_max_scs - current limit on number of start conditions
  1468. X * scset - set of rules active in start condition
  1469. X * scbol - set of rules active only at the beginning of line in a s.c.
  1470. X * scxclu - true if start condition is exclusive
  1471. X * sceof - true if start condition has EOF rule
  1472. X * scname - start condition name
  1473. X * actvsc - stack of active start conditions for the current rule
  1474. X */
  1475. X
  1476. Xextern int lastsc, current_max_scs, *scset, *scbol, *scxclu, *sceof, *actvsc;
  1477. Xextern char **scname;
  1478. X
  1479. X
  1480. X/* variables for dfa machine data:
  1481. X * current_max_dfa_size - current maximum number of NFA states in DFA
  1482. X * current_max_xpairs - current maximum number of non-template xtion pairs
  1483. X * current_max_template_xpairs - current maximum number of template pairs
  1484. X * current_max_dfas - current maximum number DFA states
  1485. X * lastdfa - last dfa state number created
  1486. X * nxt - state to enter upon reading character
  1487. X * chk - check value to see if "nxt" applies
  1488. X * tnxt - internal nxt table for templates
  1489. X * base - offset into "nxt" for given state
  1490. X * def - where to go if "chk" disallows "nxt" entry
  1491. X * nultrans - NUL transition for each state
  1492. X * NUL_ec - equivalence class of the NUL character
  1493. X * tblend - last "nxt/chk" table entry being used
  1494. X * firstfree - first empty entry in "nxt/chk" table
  1495. X * dss - nfa state set for each dfa
  1496. X * dfasiz - size of nfa state set for each dfa
  1497. X * dfaacc - accepting set for each dfa state (or accepting number, if
  1498. X *    -r is not given)
  1499. X * accsiz - size of accepting set for each dfa state
  1500. X * dhash - dfa state hash value
  1501. X * numas - number of DFA accepting states created; note that this
  1502. X *    is not necessarily the same value as num_rules, which is the analogous
  1503. X *    value for the NFA
  1504. X * numsnpairs - number of state/nextstate transition pairs
  1505. X * jambase - position in base/def where the default jam table starts
  1506. X * jamstate - state number corresponding to "jam" state
  1507. X * end_of_buffer_state - end-of-buffer dfa state number
  1508. X */
  1509. X
  1510. Xextern int current_max_dfa_size, current_max_xpairs;
  1511. Xextern int current_max_template_xpairs, current_max_dfas;
  1512. Xextern int lastdfa, lasttemp, *nxt, *chk, *tnxt;
  1513. Xextern int *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss, *dfasiz;
  1514. Xextern union dfaacc_union
  1515. X    {
  1516. X    int *dfaacc_set;
  1517. X    int dfaacc_state;
  1518. X    } *dfaacc;
  1519. Xextern int *accsiz, *dhash, numas;
  1520. Xextern int numsnpairs, jambase, jamstate;
  1521. Xextern int end_of_buffer_state;
  1522. X
  1523. X/* variables for ccl information:
  1524. X * lastccl - ccl index of the last created ccl
  1525. X * current_maxccls - current limit on the maximum number of unique ccl's
  1526. X * cclmap - maps a ccl index to its set pointer
  1527. X * ccllen - gives the length of a ccl
  1528. X * cclng - true for a given ccl if the ccl is negated
  1529. X * cclreuse - counts how many times a ccl is re-used
  1530. X * current_max_ccl_tbl_size - current limit on number of characters needed
  1531. X *    to represent the unique ccl's
  1532. X * ccltbl - holds the characters in each ccl - indexed by cclmap
  1533. X */
  1534. X
  1535. Xextern int lastccl, current_maxccls, *cclmap, *ccllen, *cclng, cclreuse;
  1536. Xextern int current_max_ccl_tbl_size;
  1537. Xextern Char *ccltbl;
  1538. X
  1539. X
  1540. X/* variables for miscellaneous information:
  1541. X * starttime - real-time when we started
  1542. X * endtime - real-time when we ended
  1543. X * nmstr - last NAME scanned by the scanner
  1544. X * sectnum - section number currently being parsed
  1545. X * nummt - number of empty nxt/chk table entries
  1546. X * hshcol - number of hash collisions detected by snstods
  1547. X * dfaeql - number of times a newly created dfa was equal to an old one
  1548. X * numeps - number of epsilon NFA states created
  1549. X * eps2 - number of epsilon states which have 2 out-transitions
  1550. X * num_reallocs - number of times it was necessary to realloc() a group
  1551. X *          of arrays
  1552. X * tmpuses - number of DFA states that chain to templates
  1553. X * totnst - total number of NFA states used to make DFA states
  1554. X * peakpairs - peak number of transition pairs we had to store internally
  1555. X * numuniq - number of unique transitions
  1556. X * numdup - number of duplicate transitions
  1557. X * hshsave - number of hash collisions saved by checking number of states
  1558. X * num_backtracking - number of DFA states requiring back-tracking
  1559. X * bol_needed - whether scanner needs beginning-of-line recognition
  1560. X */
  1561. X
  1562. Xextern char *starttime, *endtime, nmstr[MAXLINE];
  1563. Xextern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
  1564. Xextern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
  1565. Xextern int num_backtracking, bol_needed;
  1566. X
  1567. Xvoid *allocate_array(), *reallocate_array();
  1568. X
  1569. X#define allocate_integer_array(size) \
  1570. X    (int *) allocate_array( size, sizeof( int ) )
  1571. X
  1572. X#define reallocate_integer_array(array,size) \
  1573. X    (int *) reallocate_array( (void *) array, size, sizeof( int ) )
  1574. X
  1575. X#define allocate_int_ptr_array(size) \
  1576. X    (int **) allocate_array( size, sizeof( int * ) )
  1577. X
  1578. X#define allocate_char_ptr_array(size) \
  1579. X    (char **) allocate_array( size, sizeof( char * ) )
  1580. X
  1581. X#define allocate_dfaacc_union(size) \
  1582. X    (union dfaacc_union *) \
  1583. X        allocate_array( size, sizeof( union dfaacc_union ) )
  1584. X
  1585. X#define reallocate_int_ptr_array(array,size) \
  1586. X    (int **) reallocate_array( (void *) array, size, sizeof( int * ) )
  1587. X
  1588. X#define reallocate_char_ptr_array(array,size) \
  1589. X    (char **) reallocate_array( (void *) array, size, sizeof( char * ) )
  1590. X
  1591. X#define reallocate_dfaacc_union(array, size) \
  1592. X    (union dfaacc_union *) \
  1593. X    reallocate_array( (void *) array, size, sizeof( union dfaacc_union ) )
  1594. X
  1595. X#define allocate_character_array(size) \
  1596. X    (Char *) allocate_array( size, sizeof( Char ) )
  1597. X
  1598. X#define reallocate_character_array(array,size) \
  1599. X    (Char *) reallocate_array( (void *) array, size, sizeof( Char ) )
  1600. X
  1601. X
  1602. X/* used to communicate between scanner and parser.  The type should really
  1603. X * be YYSTYPE, but we can't easily get our hands on it.
  1604. X */
  1605. Xextern int yylval;
  1606. X
  1607. X
  1608. X/* external functions that are cross-referenced among the flex source files */
  1609. X
  1610. X
  1611. X/* from file ccl.c */
  1612. X
  1613. Xextern void ccladd PROTO((int, int));    /* Add a single character to a ccl */
  1614. Xextern int cclinit PROTO(());    /* make an empty ccl */
  1615. Xextern void cclnegate PROTO((int));    /* negate a ccl */
  1616. X
  1617. X/* list the members of a set of characters in CCL form */
  1618. Xextern void list_character_set PROTO((FILE*, int[]));
  1619. X
  1620. X
  1621. X/* from file dfa.c */
  1622. X
  1623. X/* increase the maximum number of dfas */
  1624. Xextern void increase_max_dfas PROTO(());
  1625. X
  1626. Xextern void ntod PROTO(());    /* convert a ndfa to a dfa */
  1627. X
  1628. X
  1629. X/* from file ecs.c */
  1630. X
  1631. X/* convert character classes to set of equivalence classes */
  1632. Xextern void ccl2ecl PROTO(());
  1633. X
  1634. X/* associate equivalence class numbers with class members */
  1635. Xextern int cre8ecs PROTO((int[], int[], int));
  1636. X
  1637. X/* associate equivalence class numbers using %t table */
  1638. Xextern int ecs_from_xlation PROTO((int[]));
  1639. X
  1640. X/* update equivalence classes based on character class transitions */
  1641. Xextern void mkeccl PROTO((Char[], int, int[], int[], int, int));
  1642. X
  1643. X/* create equivalence class for single character */
  1644. Xextern void mkechar PROTO((int, int[], int[]));
  1645. X
  1646. X
  1647. X/* from file gen.c */
  1648. X
  1649. Xextern void make_tables PROTO(());    /* generate transition tables */
  1650. X
  1651. X
  1652. X/* from file main.c */
  1653. X
  1654. Xextern void flexend PROTO((int));
  1655. X
  1656. X
  1657. X/* from file misc.c */
  1658. X
  1659. X/* write out the actions from the temporary file to lex.yy.c */
  1660. Xextern void action_out PROTO(());
  1661. X
  1662. X/* true if a string is all lower case */
  1663. Xextern int all_lower PROTO((register Char *));
  1664. X
  1665. X/* true if a string is all upper case */
  1666. Xextern int all_upper PROTO((register Char *));
  1667. X
  1668. X/* bubble sort an integer array */
  1669. Xextern void bubble PROTO((int [], int));
  1670. X
  1671. X/* shell sort a character array */
  1672. Xextern void cshell PROTO((Char [], int, int));
  1673. X
  1674. Xextern void dataend PROTO(());    /* finish up a block of data declarations */
  1675. X
  1676. X/* report an error message and terminate */
  1677. Xextern void flexerror PROTO((char[]));
  1678. X
  1679. X/* report a fatal error message and terminate */
  1680. Xextern void flexfatal PROTO((char[]));
  1681. X
  1682. X/* report an error message formatted with one integer argument */
  1683. Xextern void lerrif PROTO((char[], int));
  1684. X
  1685. X/* report an error message formatted with one string argument */
  1686. Xextern void lerrsf PROTO((char[], char[]));
  1687. X
  1688. X/* spit out a "# line" statement */
  1689. Xextern void line_directive_out PROTO((FILE*));
  1690. X
  1691. X/* generate a data statment for a two-dimensional array */
  1692. Xextern void mk2data PROTO((int));
  1693. X
  1694. Xextern void mkdata PROTO((int));    /* generate a data statement */
  1695. X
  1696. X/* return the integer represented by a string of digits */
  1697. Xextern int myctoi PROTO((Char []));
  1698. X
  1699. X/* write out one section of the skeleton file */
  1700. Xextern void skelout PROTO(());
  1701. X
  1702. X/* output a yy_trans_info structure */
  1703. Xextern void transition_struct_out PROTO((int, int));
  1704. X
  1705. X
  1706. X/* from file nfa.c */
  1707. X
  1708. X/* add an accepting state to a machine */
  1709. Xextern void add_accept PROTO((int, int));
  1710. X
  1711. X/* make a given number of copies of a singleton machine */
  1712. Xextern int copysingl PROTO((int, int));
  1713. X
  1714. X/* debugging routine to write out an nfa */
  1715. Xextern void dumpnfa PROTO((int));
  1716. X
  1717. X/* finish up the processing for a rule */
  1718. Xextern void finish_rule PROTO((int, int, int, int));
  1719. X
  1720. X/* connect two machines together */
  1721. Xextern int link_machines PROTO((int, int));
  1722. X
  1723. X/* mark each "beginning" state in a machine as being a "normal" (i.e.,
  1724. X * not trailing context associated) state
  1725. X */
  1726. Xextern void mark_beginning_as_normal PROTO((register int));
  1727. X
  1728. X/* make a machine that branches to two machines */
  1729. Xextern int mkbranch PROTO((int, int));
  1730. X
  1731. Xextern int mkclos PROTO((int));    /* convert a machine into a closure */
  1732. Xextern int mkopt PROTO((int));    /* make a machine optional */
  1733. X
  1734. X/* make a machine that matches either one of two machines */
  1735. Xextern int mkor PROTO((int, int));
  1736. X
  1737. X/* convert a machine into a positive closure */
  1738. Xextern int mkposcl PROTO((int));
  1739. X
  1740. Xextern int mkrep PROTO((int, int, int));    /* make a replicated machine */
  1741. X
  1742. X/* create a state with a transition on a given symbol */
  1743. Xextern int mkstate PROTO((int));
  1744. X
  1745. Xextern void new_rule PROTO(());    /* initialize for a new rule */
  1746. X
  1747. X
  1748. X/* from file parse.y */
  1749. X
  1750. X/* write out a message formatted with one string, pinpointing its location */
  1751. Xextern void format_pinpoint_message PROTO((char[], char[]));
  1752. X
  1753. X/* write out a message, pinpointing its location */
  1754. Xextern void pinpoint_message PROTO((char[]));
  1755. X
  1756. Xextern void synerr PROTO((char []));    /* report a syntax error */
  1757. Xextern int yyparse PROTO(());    /* the YACC parser */
  1758. X
  1759. X
  1760. X/* from file scan.l */
  1761. X
  1762. Xextern int flexscan PROTO(());    /* the Flex-generated scanner for flex */
  1763. X
  1764. X/* open the given file (if NULL, stdin) for scanning */
  1765. Xextern void set_input_file PROTO((char*));
  1766. X
  1767. Xextern int yywrap PROTO(());    /* wrapup a file in the lexical analyzer */
  1768. X
  1769. X
  1770. X/* from file sym.c */
  1771. X
  1772. X/* save the text of a character class */
  1773. Xextern void cclinstal PROTO ((Char [], int));
  1774. X
  1775. X/* lookup the number associated with character class */
  1776. Xextern int ccllookup PROTO((Char []));
  1777. X
  1778. Xextern void ndinstal PROTO((char[], Char[]));    /* install a name definition */
  1779. Xextern void scinstal PROTO((char[], int));    /* make a start condition */
  1780. X
  1781. X/* lookup the number associated with a start condition */
  1782. Xextern int sclookup PROTO((char[]));
  1783. X
  1784. X
  1785. X/* from file tblcmp.c */
  1786. X
  1787. X/* build table entries for dfa state */
  1788. Xextern void bldtbl PROTO((int[], int, int, int, int));
  1789. X
  1790. Xextern void cmptmps PROTO(());    /* compress template table entries */
  1791. Xextern void inittbl PROTO(());    /* initialize transition tables */
  1792. Xextern void mkdeftbl PROTO(());    /* make the default, "jam" table entries */
  1793. X
  1794. X/* create table entries for a state (or state fragment) which has
  1795. X * only one out-transition */
  1796. Xextern void mk1tbl PROTO((int, int, int, int));
  1797. X
  1798. X/* place a state into full speed transition table */
  1799. Xextern void place_state PROTO((int*, int, int));
  1800. X
  1801. X/* save states with only one out-transition to be processed later */
  1802. Xextern void stack1 PROTO((int, int, int, int));
  1803. X
  1804. X
  1805. X/* from file yylex.c */
  1806. X
  1807. Xextern int yylex PROTO(());
  1808. X
  1809. X
  1810. X/* The Unix kernel calls used here */
  1811. X
  1812. Xextern int read PROTO((int, char*, int));
  1813. Xextern int unlink PROTO((char*));
  1814. Xextern int write PROTO((int, char*, int));
  1815. END_OF_FILE
  1816. if test 28965 -ne `wc -c <'flexdef.h'`; then
  1817.     echo shar: \"'flexdef.h'\" unpacked with wrong size!
  1818. fi
  1819. # end of 'flexdef.h'
  1820. fi
  1821. echo shar: End of archive 6 \(of 13\).
  1822. cp /dev/null ark6isdone
  1823. MISSING=""
  1824. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 ; do
  1825.     if test ! -f ark${I}isdone ; then
  1826.     MISSING="${MISSING} ${I}"
  1827.     fi
  1828. done
  1829. if test "${MISSING}" = "" ; then
  1830.     echo You have unpacked all 13 archives.
  1831.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1832. else
  1833.     echo You still need to unpack the following archives:
  1834.     echo "        " ${MISSING}
  1835. fi
  1836. ##  End of shell archive.
  1837. exit 0
  1838. -- 
  1839. Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
  1840. Mail comments to the moderator at <amiga-request@uunet.uu.net>.
  1841. Post requests for sources, and general discussion to comp.sys.amiga.
  1842.